package com.yz.design.responsibilityDegin;

import cn.hutool.json.JSON;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * 推送消息Handler
 */
@Slf4j
public class JpushOrderHandler extends AbstractMessageHandler<Object, Message> {
    @Override
    public Object handleMessage(Message message) {
        if (message.getTopic().equals(getTopic()) ) {
            //避免消费到其他消息 json转换报错
            log.info(" 监听到推送消息,[topic:" + message.getTopic() + "], [tag:" + message.getTag() + "]。开始解析...");
            try {
                // res 是生产者传过来的消息内容
                String body = message.getBody();
                //执行推送消息
                return new Object();
            } catch (Exception e) {
                log.error("MessageListener.consume error:" + e.getMessage(), e);
                return new Object();
            }
        } else {
            if (nextHandler == null) {
                log.info("未匹配到topic:{}, tag:{}跳过,", message.getTopic(), message.getTag());
                return new Object();
            }
            return nextHandler.handleMessage(message);
        }
    }
}